home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / raytrace / radiance / nextrad.lha / NeXtRad / datastruct.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-22  |  4.2 KB  |  164 lines

  1. /* datastruct.h */
  2. /* This file contains the data structure for the internal representation
  3.    of the scene.  Also contains several basic datastructures used throughout */
  4. /* Written by : Jason R. Wilson                     */
  5. /* last modified 2/21/93 */
  6.  
  7.  
  8. #define Wtol 0.0001 /* used for clipping in front of eye */
  9.  
  10. #define irint rint /* next implementation only */
  11.  
  12. typedef enum {false , true} Boolean; 
  13.  
  14. /*----------------------------------------------------------------------*/
  15.  
  16. typedef struct
  17. {
  18.    double x, y, z;
  19. }
  20. Point;
  21.  
  22. /*----------------------------------------------------------------------*/
  23.  
  24. typedef struct
  25. {
  26.    double dx, dy, dz;
  27. }
  28. Vector;
  29.  
  30. /*----------------------------------------------------------------------*/
  31.  
  32. typedef struct
  33. {
  34.    double hom[4];
  35. }
  36. Homog;
  37.  
  38. /*----------------------------------------------------------------------*/
  39.  
  40. typedef struct
  41. {
  42.    double mat[16];
  43. }
  44. Matrix;
  45.  
  46. /*----------------------------------------------------------------------*/
  47.  
  48. typedef struct
  49. {
  50.    unsigned char r,g,b;
  51. UColor;
  52.  
  53. /*----------------------------------------------------------------------*/
  54.  
  55. typedef struct
  56. {
  57.    double r,g,b;
  58. Color;
  59.  
  60. /*----------------------------------------------------------------------*/
  61.  
  62. typedef struct
  63. {
  64.    double Wl,Wr,Wb,Wt;
  65. }
  66. Window;
  67.  
  68. /*----------------------------------------------------------------------*/
  69.  
  70. typedef struct vertexlistcell /* stores a pointer to a vertex */
  71. {
  72.    struct vertexcell *Vertex;
  73.    struct vertexlistcell *Rest;
  74. VertexListCell;
  75.  
  76. /*----------------------------------------------------------------------*/
  77.  
  78. typedef struct polygonlistcell /* stores a pointer to a polygon */
  79. {
  80.    struct polygoncell *Polygon;
  81.    struct polygonlistcell *Rest;
  82. }
  83. PolygonListCell;
  84.  
  85. /*----------------------------------------------------------------------*/
  86.  
  87. typedef struct visvertexcell 
  88. {
  89.    Color B; /* the color of the vertex */
  90.    Homog ViewPosition; /* the view position */
  91.    struct visvertexcell *Next;
  92. }
  93. VisVertexCell;
  94.    
  95. /*----------------------------------------------------------------------*/
  96.  
  97. typedef struct polygoncell
  98. {
  99.    struct vertexlistcell *Vertices; /* The vertices of the polygon */
  100.    VisVertexCell         *VisVertices; /* The visible vertices */
  101.    Vector Normal; /* The polygon normal */
  102.    struct polygoncell *Next;
  103.    struct polygoncell *Subs[4];
  104.    int ID; /* unique identifier for polygon */
  105.    Boolean Textured; /* is it a textured polygon */
  106.    Color B; /* the radiosity (color) of the polygon */
  107.    Color R; /* the reflectivity of the cell */
  108.    Color E; /* the emmission values for the cell */
  109.    Boolean Culled;  /* has the poly been culled? */
  110. PolygonCell;
  111.  
  112.  
  113. /*----------------------------------------------------------------------*/
  114. typedef struct vertexcell
  115. {
  116.    Point  WorldPosition; /* the world coordinates */
  117.    Homog ViewPosition; /* the view coord. */
  118.    Vector Normal; /* the vertex normal */
  119.    int Number; 
  120.    double Intensity; 
  121.    struct polygonlistcell *Polygons; /*The polygons that contain this vertex */
  122.    struct vertexcell *Next;
  123.    Color B;
  124. }
  125. VertexCell;
  126.  
  127. /*----------------------------------------------------------------------*/
  128.  
  129. typedef struct objectcell
  130. {
  131.    int Number; /* uniquely identifies the object */
  132.    Color **TextureMap; /* contains the texture map if the object is textured */
  133.    int mapHeight,mapWidth; /* texture info. (see above) */
  134.    int NoofVertices, NoofPolygons; /* Number of vertices and polygons */
  135.    VertexCell *VertexHead;    /* The list of vertices for the object */
  136.    PolygonCell *PolygonHead;  /* The list of polygons for the object */
  137.    Matrix Transform; /* The transform matrix for the object */
  138.    Matrix InverseTransform; /* the inverse transform matrix for the object */
  139.    struct objectcell *Next; /* the next object in the list */
  140.    int SubFactor; /* specifies how many times the initial mesh should be subdivided */
  141.    Boolean ShouldAdapt; /* should this object be adaptively subdivided */
  142. ObjectCell;
  143.  
  144. ObjectCell *ObjectHead; /* declare here for all to see */
  145.  
  146. void InitVertexListCell (VertexListCell *VertList);
  147. void InitPolygonListCell (PolygonListCell *PolyList);
  148. void InitVisVertexCell (VisVertexCell *VisVert);
  149. void InitPolygonCell (PolygonCell *Poly);
  150. void InitVertexCell (VertexCell *Vert);
  151. void InitObjectCell (ObjectCell *Object);   
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.